home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / documentation / jre / HelloWorld.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-17  |  486 b   |  21 lines

  1.  
  2. #include <jre_demo_HelloWorld.h>
  3. #include <jni_md.h>
  4.  
  5. JNIEXPORT void JNICALL Java_jre_demo_HelloWorld_nativeMethod
  6. (JNIEnv *env, jclass clazz, jstring str) {
  7.     
  8.     const char *cstr;
  9.  
  10.     if (str == NULL) {
  11.     /* raise exception */
  12.     jclass nullPtr = (*env)->FindClass(env, "java/lang/NullPointerException");
  13.     (*env)->ThrowNew(env, nullPtr, "null string");
  14.     return;
  15.     }
  16.  
  17.     cstr = (*env)->GetStringUTFChars(env, str, (jboolean *)NULL);
  18.  
  19.     printf("Window Title is '%s'\n", cstr);
  20. }
  21.